package homework_9_29;

import javax.xml.stream.events.Characters;
import java.util.HashMap;
import java.util.Set;

/**
 * @Author: Tiangle
 * @Date: 2021/9/29 18:49
 */
public class W_1 {
    public static void main(String[] args) {
        String s = "abfdjslajfdkljsalkfjdl";
        System.out.println(getNum(s));

    }
    public static String getNum(String s){
        HashMap<Character,Integer> hm = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (hm.get(c)==null){
                hm.put(c,1);
            }else{
                hm.put(c,hm.get(c)+1);
            }
        }
        String re = "";
        Set<Character> characters = hm.keySet();
        for (Character c :
                characters) {
            re += c +"("+hm.get(c)+")";
        }
        return re;
    }
}
